package cn.ibizlab.util.adapter.security;

import cn.ibizlab.util.adapter.service.SysRuntimeModelService;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
import org.springframework.security.core.Authentication;

public class DefaultAdapterMethodSecurityExpressionHandler extends org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler {

    @Autowired
    SysRuntimeModelService sysRuntimeModelService;

    @Override
    protected MethodSecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication, MethodInvocation invocation) {
        DefaultAdapterMethodSecurityExpression root = new DefaultAdapterMethodSecurityExpression(authentication);
        root.setThis(invocation.getThis());
        root.setTrustResolver(getTrustResolver());
        root.setPermissionEvaluator(getPermissionEvaluator());
        root.setRoleHierarchy(getRoleHierarchy());
        root.setSysRuntimeModelService(sysRuntimeModelService);
        return root;
    }

}